package com.sikaryofficial.backend.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 文章状态枚举
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum ArticleStatusEnum {
    /**
     * 文章状态
     */
    NORMAL(ContentConstant.CONTENT_STATUS_NORMAL, ArticleConstant.STATUS_NORMAL),
    SHIELD(ContentConstant.CONTENT_STATUS_SHIELD, ArticleConstant.STATUS_SHIELD),
    REPORT(ContentConstant.CONTENT_STATUS_REPORT, ArticleConstant.STATUS_REPORT),
    ;
    private final Integer code;
    private final String name;

    public static ArticleStatusEnum getNameByCode(Integer code) {
        return Arrays.stream(ArticleStatusEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) && pointRuleEnum.getCode().equals(code))
                .findFirst().orElse(NORMAL);
    }
}
